This document provides instructions for downloading and installing R and RStudio on a Windows machine. (Note: I do not personally own a Windows machine so some of these instructions might be outdated. If the installation instructions you face are different from what is outlined here, please let me know.)
NOTE: Because of backward dependency issues, some code that we talk about in class will NOT work if you do not download the latest version of R/RStudio. Because the class is pretty large, I will NOT be able to address issues due to older versions in class.
Make sure that you have about 500 MB of free space on your machine. We will need this space to install both R and RStudio, and when the program installs the compressed files expand to take much more space.
Go to this website.
Click on the “Download R 3.6.1 for Windows” link at the top of the page. Your download should start.
R is now installed on your computer.
Note: This version of R should run with no problems on Windows 7 or later.
The >
character is called the prompt and is the place where we enter commands for the program to interpret. For instance, if you type 25+26
followed by the return/enter key, you will see:
25+26
## [1] 51
q()
and htting the return key.q()
R will ask you if you want to save your work. Don’t save it. You have now left R.
We are not going to use R this way often, as we will use an integrated environment called RStudio.
Go to this website.
Under the “Installers for Supported Platforms” section, click on the “RStudio 1.2.5001 - Windows 7+ (64-bit)” link. The file download will begin.
Once the file has been downloaded, click on it and walk through the installation process.
C:\Program Files\RStudio
.RStudio is now installed on your computer.
Note: For RStudio to work, R needs to be installed first.
Just as in R, the >
character in the Console window is where we enter commands for the program to interpret.
To exit RStudio, click on the red X at the top-right corner of the window. If prompted to save the workspace, do not save it.
In the Windows system, path names use backslashes, e.g. C:\Users\username\RWork\
. R, on the other hand, inherits its file and folder naming conventions from Unix which uses forward slashes instead: C:/Users/susan/RWork/
.
In Unix conventions, backslashes are actually used for a different purpose (to isolate special characters and stop them from being immediately interpreted).
As a rule, to avoid problems, we should avoid naming directories and files with spaces and special characters.
If you already have an important directory with a space in its name, know that when trying to reference that directory in R, you have to put a backslash in front of each space.
Note: (“C:\Path\To\A\File”) is the same as (“C:/Path/To/A/File”).